<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- 我们界面上，其实有三个同样的业务功能 -->
    <!-- 点击按钮，让数字自增 -->
    <!-- <div>
      {{count}} <button @click="fn">自增+1</button>
    </div>
    <div>
      {{count1}} <button @click="fn1">自增+1</button>
    </div>
    <div>
      {{count2}} <button @click="fn2">自增+1</button>
    </div> -->
    <count-add></count-add>
    <count-add></count-add>
    <count-add></count-add>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 使用组件
    Vue.component('count-add',{
      template: `<div>{{count}} <button @click="fn">自增+1</button></div>`,
      data () {
        return {
          count: 0
        }
      },
      methods: {
        fn () {
          this.count ++
        }
      }
    })
    // 根实例
    new Vue({
      el: '#app'
    })
  </script>
  <!-- <script>
    new Vue({
      el: '#app',
      data: {
        count: 0,
        count1: 0,
        count2: 0
      },
      methods: {
        fn () {
          this.count ++
        },
        fn1 () {
          this.count1 ++
        },
        fn2 () {
          this.count2 ++
        }
      }
    })
  </script> -->
</body>
</html>